/**
 * @author   zhangyp
 * @created  2013-9-22 下午5:01:22
 * @email    zviolet@163.com
 * TODO      检查网络状态并进行设置
 */
package com.bible.fire.local;

import com.bible.fire.util.AndroidUtil;
import com.bible.fire.util.WindowUtil;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;

public class NetworkManager {
	
	public static void checkNetwork(Context context){
		if( !AndroidUtil.isNetworkAvailable() ){
			final Context fcontext = context;
			Runnable runable = new Runnable(){
				@Override
				public void run() {
					Intent intent=null;
					//判断系统的版本  即API大于10 就是3.0或以上版本 
	                if(android.os.Build.VERSION.SDK_INT>10){
	                	//打开无线和网络的设置界面
	                    //intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
	                	//打开wi-fi的设置界面
	                    intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
	                }else{
	                    intent = new Intent();
	                    ComponentName component = new ComponentName("com.android.settings","com.android.settings.WirelessSettings");
	                    intent.setComponent(component);
	                    intent.setAction(Intent.ACTION_VIEW);
	                }
	                fcontext.startActivity(intent);
	            }				
			};
			WindowUtil.showOperateDialog(context, "网络未连接", "提示", runable);
		}
	}

}
